package com.mediacloud.app.newsmodule.fragment.baoliao.activity;

import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.text.TextUtils;
import android.util.TypedValue;
import android.view.View;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.fragment.app.FragmentManager;
import androidx.fragment.app.FragmentTransaction;

import com.mediacloud.app.model.activity.BaseBackActivity;
import com.mediacloud.app.newsmodule.R;
import com.mediacloud.app.newsmodule.fragment.baoliao.frag.BaoLiaoRankListFragment;

/**
 * 爆料排行榜
 */
public class BaoLiaoRankActivity extends BaseBackActivity {

    BaoLiaoRankListFragment fragment;
    TextView textView;

    public static void startActivity(Context context, String title, String catalogId) {
        Intent intent = new Intent();
        intent.setClass(context, BaoLiaoRankActivity.class);
        intent.putExtra("title", title);
        intent.putExtra("id", catalogId);
        context.startActivity(intent);
    }

    @Override
    public int getLayoutResID() {
        return R.layout.activity_bao_liao;
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
//        mTitlebar_MoreContainer.setVisibility(View.VISIBLE);
//        mMoreText.setVisibility(View.VISIBLE);
//        mTitlebar_More.setVisibility(View.GONE);
//        setMoreText(R.string.faobiao);

       /* mMoreText.setVisibility(View.VISIBLE);
        mTitlebar_More.setVisibility(View.GONE);
        mMoreText.setText(getString(R.string.publish));
        mMoreText.setTextColor(0x00ffffff);
        mMoreText.setTextSize(TypedValue.COMPLEX_UNIT_PX, getResources().getDimension(R.dimen.dimen14));
        mMoreText.setBackground(ContextCompat.getDrawable(this,R.drawable.baoliao_submit_shape));
        RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) mMoreText.getLayoutParams();
        params.height = RelativeLayout.LayoutParams.WRAP_CONTENT;
        params.width = RelativeLayout.LayoutParams.WRAP_CONTENT;
        int left = getResources().getDimensionPixelSize(R.dimen.dimen10);
        int top = getResources().getDimensionPixelSize(R.dimen.dimen2);
        params.setMarginEnd(left);
        mMoreText.setLayoutParams(params);
        mMoreText.setPadding(left, top, left, top);*/
        textView = findViewById(R.id.text_notice);
        textView.setVisibility(View.VISIBLE);
        String title = getIntent().getStringExtra("title");
        title = TextUtils.isEmpty(title) ? getResources().getString(R.string.baoliao_i_want) : title;
        setTitle(title);
        if (mTitlebar_name != null) {
            mTitlebar_name.getPaint().setFakeBoldText(false);
            mTitlebar_name.setIncludeFontPadding(false);
            mTitlebar_name.setTextSize(TypedValue.COMPLEX_UNIT_PX, getResources().getDimensionPixelSize(R.dimen.dimen20sp));
        }
        FragmentManager manager = getSupportFragmentManager();
        FragmentTransaction transaction = manager.beginTransaction();
        fragment = new BaoLiaoRankListFragment();
        fragment.setArguments(getIntent().getExtras());
        transaction.add(R.id.baoliao_container, fragment);
        transaction.commitNowAllowingStateLoss();
    }

    @Override
    protected void moreClicked() {
//        if (fragment != null) {
//            fragment.onSubmit();
//        }
    }

    @Override
    public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
        super.onRequestPermissionsResult(42, permissions, grantResults);
    }
}